Ubuntu 非root远程登录

576次阅读
没有评论

共计 430 个字符,预计需要花费 2 分钟才能阅读完成。

服务器使用Ubuntu,做点简单处理,使用非root用户。

ssh远程登录

首先保证能通过root连接,可用root用户执行以下命令:

chown root:root -R /root/.ssh/
chmod 700 /root/.ssh/
chmod 600 /root/.ssh/authorized_keys

chown me:me -R /home/lingdou/.ssh/
chmod 700 /home/me/.ssh/
chmod 600 /home/me/.ssh/authorized_keys

其中 me 是要登录的用户名,需要提前创建好。

将用户加入sudo

gpasswd -a me sudo
echo "me ALL=(ALL) NOPASSWD: ALL" | (EDITOR="tee -a" visudo)

禁用密码和root登录

修改 /etc/ssh/sshd_config

PermitRootLogin no
PasswordAuthentication no

重启服务:service sshd restart

正文完
 
评论(没有评论)